#include "app.hpp"

Settings settings;
Status status;
DJ6 dj6;
Chassis chassis(settings.wheel_pid);

static void app_can_callback(const uint32_t id, uint8_t data[8]) {
    chassis.ParseCAN(id, data);
}

static void app_rc_callback(const uint8_t *data, const uint16_t size) {
    dj6.ParseData(data, size);
}

void app_init() {
    BSP_Init();

    // 设置中断回调函数
    BSP_CAN_SetCallback(app_can_callback);
    BSP_UART_RC_SetCallback(app_rc_callback);

    osThreadDef(task_led, task_led_entry, osPriorityIdle, 0, 128);
    osThreadCreate(osThread(task_led), NULL);

    osThreadDef(task_chassis, task_chassis_entry, osPriorityHigh, 0, 256);
    osThreadCreate(osThread(task_chassis), NULL);
}
